////拿到由登录界面传过来的id
$(function(){
	var path = window.location.href;
	if(path.indexOf("=")>0){
		var id = path.substring(path.indexOf("=")+1);
		$("#topid").html("hi,"+id);
	}
	
});

//banner部分
//$.ajax({
//	type:"get",
//	url:"/api/meetingroom/getAdvertisements",
//	async:true,
//	dataType:"json",
//	success:function(data){
////		console.log(data.data);
//		var list=data.data;
//		var str="";
//		for(var i=0;i<list.length;i++){
////			console.log(list[i].imgUrl);
//			str += '<li><img src="'+list[i].imgUrl+'"/></li>';
////			console.log(str);
//			$('.am-slides').html(str);
//		}
//	}
//});

//分类
//一级分类
$.ajax({
	type:"get",
	url:"/api/meetingroom/getShopclassify",
	data:{"id":"0123456789"},
	async:true,
	dataType:"json",
	success:function(data){
		var list=data.data;
//		console.log(list);
		var str="";
		for (var i=0;i<list.length;i++) {
			str+=
				'<li class="appliance js_toggle relative first">'+
					'<div class="category-info">'+
						'<h3 class="category-name b-category-name"><a class="ml-22">'+list[i].warehousename+'</a></h3>'+
						'<em>&gt;</em>'+
					'</div>'+
					'<div class="menu-item menu-in top">'+
						'<div class="area-in">'+
							'<div class="area-bg">'+
								'<div class="menu-srot">'+
									'<div class="sort-side"></div>'+
								'</div>'+
							'</div>'+
						'</div>'+
					'</div>'+
				'</li>';
			$(".category-list").html(str);
		}
		$('.first').each(function(num){
			var str1="";
			var str2="";
			var that=$(this);
			$.ajax({
				type:"get",
				url:"/api/meetingroom/getShopSort",
				async:true,
				data:{"id":list[num].id},
				dataType:"json",
				success:function(data){
					var list=data.data;
					console.log(list);
					for (var j=0;j<list.length;j++){
						var a=list[j].levelDown;
						for(var k=0;k<a.length;k++){
							str2+=  '<dd>'+
//										'<img src="'+a[k].imgUrl+'"/>'+
										'<a href="search.html?id='+a[k].id+'" target=_blank><span>'+a[k].warehousename+'</span></a>'+
									'</dd>';
								
						}
						str1+='<dl class="dl-sort">'+'<dt><span>'+list[j].warehousename+'</span></dt>'+str2+'</dl>';
					}
					that.find('.sort-side').html(str1);
					setHover();
					
				}
			});
		});
		
	}
});


//今日推荐
$.ajax({
	type:"get",
	url:"/api/meetingroom/getSpecialOrHotGoods",
	async:true,
	dataType:"json",
	success:function(data){
		var list=data.content.maps0;
		var str="";
		for(var i=0;i<4;i++){
			str+='<div class="am-u-sm-4 am-u-lg-3">'+
					'<div class="info">'+
						'<h3>'+list[i].goodName+'</h3>'+
						'<h4>￥'+list[i].goodPrice+'</h4>'+
					'</div>'+
					'<div class="recommendationMain one">'+
						'<a href="introduction.html?id='+list[i].goodsId+'" target="_blank"><img src="'+list[i].imgUrl+'"></img></a>'+
					'</div>'+
				'</div>	';
		}
		$('#recommend').html(str);
	}
})

function setHover(){
	$("li").hover(function() {
		$(".category-content .category-list li.first .menu-in").css("display", "none");
		$(".category-content .category-list li.first").removeClass("hover");
		$(this).addClass("hover");
		$(this).children("div.menu-in").css("display", "block")
	}, function() {
		$(this).removeClass("hover")
		$(this).children("div.menu-in").css("display", "block")
	});
}
//促销商品列表
$("#more").on("click ",function(){
	$.ajax({
		type:"get",
		url:"/api/meetingroom/getSalePromotionList",
		async:true,
		dataType:"json",
		data:{"name":"0","page":"1","pageSize":"4"},
		success:function(data){
			var list=data.data;
			for(var i = 0;i<list.length;i++){
				var imgUrl=list[i].imgUrl;
				console.log(imgUrl);
			}
			localStorage.setItem("imgUrl",imgUrl);
		}
	});
});
